import instance from "../utils/axios_config.js";

export {getAdPage,queryAd,deleAd,editAd,addAd,getPhoneName,offAdApi,onAdApi}

// 查询列表接口
const getAdPage = (params) => {
    return instance({
        url: '/ad',
        method: 'get',
        params
    })
}

//获取二手手机的分类列表
const getPhoneName=()=>{
 return instance({
    url:'/category/phone',
    method:'get'
 })
}

// 编辑页面搜索
const queryAd = (params) => {
    return instance({
        url: `/ad/search`,
        method: 'get',
        params
    })
}

// 下架广告
const offAdApi = (id) => {
    return instance({
        url: '/ad/off/' + id,
        method: 'put'
    })
}


// 上架广告
const onAdApi = (id) => {
    return instance({
        url: '/ad/on/' + id,
        method: 'put'
    })
}

// 删除当前列的接口
const deleAd = (id) => {
    return instance({
        url: '/ad/delete/' + id,
        method: 'delete'
    })
}

// 修改接口
const editAd = (params) => {
    return instance({
        url: '/ad/update',
        method: 'put',
        data: {...params}
    })
}

// 新增接口
const addAd = (params) => {
    return instance({
        url: '/ad/save',
        method: 'post',
        data: {...params}
    })
}